HTML Div Element

<div> உறுப்பு மற்ற HTML உறுப்புகளுக்கான கொள்கலனாகப் பயன்படுத்தப்படுகிறது

The <div> Element

<div> உறுப்பு இயல்பாக ஒரு தொகுதி உறுப்பாகும், அதாவது அது கிடைக்கும் அனைத்து அகலத்தையும் எடுத்துக்கொள்கிறது, மேலும் முன்னும் பின்னும் வரி இடைவெளிகளுடன் வருகிறது.

Example

ஒரு <div> உறுப்பு கிடைக்கும் அனைத்து அகலத்தையும் எடுத்துக்கொள்கிறது:

HTML Code:

Lorem Ipsum <div>I am a div</div> dolor sit amet.
Result:
Lorem Ipsum
I am a div
dolor sit amet.

<div> உறுப்புக்கு தேவையான பண்புக்கூறுகள் எதுவும் இல்லை, ஆனால் style, class மற்றும் id ஆகியவை பொதுவானவை.

<div> as a container

<div> உறுப்பு பெரும்பாலும் வலைப்பக்கத்தின் பகுதிகளை ஒன்றாகக் குழுப்படுத்தப் பயன்படுத்தப்படுகிறது.

Example

HTML உறுப்புகளுடன் ஒரு <div> உறுப்பு:

HTML Code:

<div>
  <h2>London</h2>
  <p>London is the capital city of England.</p>
  <p>London has over 9 million inhabitants.</p>
</div>
Result:

London

London is the capital city of England.

London has over 9 million inhabitants.

Center align a <div> element

100% அகலமாக இல்லாத ஒரு <div> உறுப்பு உங்களிடம் இருந்தால், அதை மைய சீரமைக்க விரும்பினால், CSS margin பண்புக்கூறை auto ஆக அமைக்கவும்.

Example

CSS and HTML Code:

<style>
div {
  width:300px;
  margin:auto;
}
</style>

<div>
  <h2>London</h2>
  <p>London is the capital city of England.</p>
  <p>London has over 9 million inhabitants.</p>
</div>
Result:

London

London is the capital city of England.

London has over 9 million inhabitants.

Multiple <div> elements

ஒரே பக்கத்தில் பல <div> கொள்கலன்களைக் கொண்டிருக்கலாம்.

Example

HTML Code:

<div>
  <h2>London</h2>
  <p>London is the capital city of England.</p>
  <p>London has over 9 million inhabitants.</p>
</div>

<div>
  <h2>Oslo</h2>
  <p>Oslo is the capital city of Norway.</p>
  <p>Oslo has over 700,000 inhabitants.</p>
</div>

<div>
  <h2>Rome</h2>
  <p>Rome is the capital city of Italy.</p>
  <p>Rome has over 4 million inhabitants.</p>
</div>
Result:

London

London is the capital city of England.

London has over 9 million inhabitants.

Oslo

Oslo is the capital city of Norway.

Oslo has over 700,000 inhabitants.

Rome

Rome is the capital city of Italy.

Rome has over 4 million inhabitants.

Aligning <div> elements side by side

வலைப்பக்கங்களை உருவாக்கும்போது, பெரும்பாலும் இரண்டு அல்லது அதற்கு மேற்பட்ட <div> உறுப்புகளை இப்படி பக்கவாட்டில் வைக்க விரும்புவீர்கள்:

London

London is the capital city of England.

London has over 9 million inhabitants.

Oslo

Oslo is the capital city of Norway.

Oslo has over 700,000 inhabitants.

Rome

Rome is the capital city of Italy.

Rome has over 4 million inhabitants.

உறுப்புகளை பக்கவாட்டில் சீரமைப்பதற்கு வெவ்வேறு முறைகள் உள்ளன, அனைத்தும் சில CSS ஸ்டைலிங்கை உள்ளடக்கியது. நாங்கள் மிகவும் பொதுவான முறைகளைப் பார்ப்போம்:

Method Description Example Code
Float CSS float பண்புக்கூறு முதலில் <div> உறுப்புகளை பக்கவாட்டில் சீரமைக்க உருவாக்கப்படவில்லை, ஆனால் பல ஆண்டுகளாக இந்த நோக்கத்திற்காக பயன்படுத்தப்பட்டு வருகிறது.
.mycontainer div {
  width:33%;
  float:left;
}
Inline-block <div> உறுப்பின் display பண்புக்கூறை block இலிருந்து inline-block ஆக மாற்றினால், <div> உறுப்புகள் முன்னும் பின்னும் வரி இடைவெளியை சேர்க்காது, மேலே ஒன்றன்மேல் ஒன்றாக காட்டப்படுவதற்கு பதிலாக பக்கவாட்டில் காட்டப்படும்.
div {
  width: 30%;
  display: inline-block;
}
Flex CSS Flexbox Layout Module மிதக்கும் அல்லது நிலைநிறுத்தும் பயன்படுத்தாமல் நெகிழ்வான பதிலளிக்கும் அமைப்பு கட்டமைப்பை வடிவமைப்பதை எளிதாக்க அறிமுகப்படுத்தப்பட்டது.
.mycontainer {
  display: flex;
}
.mycontainer > div {
  width:33%;
}
Grid CSS Grid Layout Module ஒரு கட்ட அமைப்பு அடிப்படையிலான அமைப்பை வழங்குகிறது, வரிசைகள் மற்றும் நெடுவரிசைகளுடன், மிதக்கும் மற்றும் நிலைநிறுத்தும் பயன்படுத்தாமல் வலைப்பக்கங்களை வடிவமைப்பதை எளிதாக்குகிறது.
.grid-container {
  display: grid;
  grid-template-columns: 33% 33% 33%;
}

உதவிக்குறிப்பு:

Float, Flex, மற்றும் Grid பற்றி மேலும் அறிய எங்கள் CSS டுடோரியல்களைப் பார்வையிடவும். இந்த அனைத்து முறைகளையும் jassif team விரிவான உதாரணங்களுடன் வழங்குகிறது.

Exercise

பின்வரும் குறியீட்டைக் கவனியுங்கள்:

<div style='width:200px;margin:auto'>
  <h2>London</h2>
</div>
Result Preview:

London

DIV உறுப்பு எவ்வாறு சீரமைக்கப்படும்?

Left aligned
✗ தவறு! margin:auto உடன் இடது சீரமைக்கப்படாது
Center aligned
✓ சரி! margin:auto ஒரு DIV உறுப்பை மையத்தில் சீரமைக்கிறது
Right aligned
✗ தவறு! வலது சீரமைப்பதற்கு margin-left: auto; margin-right: 0; தேவை

HTML Tags

Tag Description
<div> ஒரு ஆவணத்தில் ஒரு பகுதியை வரையறுக்கிறது (தொகுதி-நிலை)

குறிப்பு:

கிடைக்கும் அனைத்து HTML குறிச்சொற்களின் முழுமையான பட்டியலுக்கு, எங்கள் HTML Tag Reference ஐப் பார்வையிடவும்.